package com.ruoyi.bzjgl.controller;

import com.ruoyi.bzjgl.service.IBzjtableService;
import com.ruoyi.bzjgl.service.IIndexService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@Api("首页")
@RestController
@RequestMapping("/sys/index")
public class IndexController extends BaseController {

    @Autowired
    private IIndexService indexService;
    @Autowired
    private IBzjtableService bzjtableService;

    @ApiOperation("获取保障金总数")
    @GetMapping("/getAmount")
    public HashMap<String, Object> getAmount()
    {
        List<String> depNames = bzjtableService.getDepList();
        HashMap<String,List<String>> depNamesMap = new HashMap<>();
        depNamesMap.put("depNames",depNames);
        return  indexService.getAmount(depNamesMap);
    }

    @ApiOperation("获取不同组织机构保障金总数table")
    @GetMapping("/getAmountGroupByOrg")
    public TableDataInfo getAmountGroupByOrg()
    {
        List<String> depNames = bzjtableService.getDepList();
        HashMap<String,List<String>> depNamesMap = new HashMap<>();
        depNamesMap.put("depNames",depNames);
        List<HashMap<String,Object>> list = indexService.getAmountGroupByOrg(depNamesMap);
        return getDataTable(list);
    }

    @ApiOperation("获取没收占比饼图")
    @GetMapping("/getMsBing")
    public AjaxResult getMsBing()
    {
        List<String> depNames = bzjtableService.getDepList();
        HashMap<String,List<String>> depNamesMap = new HashMap<>();
        depNamesMap.put("depNames",depNames);
        List<HashMap<String,Object>> map = indexService.getMsBing(depNamesMap);
        AjaxResult ajax = AjaxResult.success();
        ajax.put("data", map);
        return ajax;
    }


    @ApiOperation("获取没收占比饼图")
    @GetMapping("/getThBing")
    public AjaxResult getThBing()
    {
        List<String> depNames = bzjtableService.getDepList();
        HashMap<String,List<String>> depNamesMap = new HashMap<>();
        depNamesMap.put("depNames",depNames);
        List<HashMap<String,Object>> map = indexService.getThBing(depNamesMap);
        AjaxResult ajax = AjaxResult.success();
        ajax.put("data", map);
        return ajax;
    }


    @ApiOperation("获取今日金额")
    @GetMapping("/getJrje")
    public AjaxResult getJrje()
    {
        List<String> depNames = bzjtableService.getDepList();
        HashMap<String,Object> map = indexService.getJrje(depNames);
        AjaxResult ajax = AjaxResult.success();
        ajax.put("data", map);
        return ajax;
    }

    @ApiOperation("获取近七日金额")
    @GetMapping("/getSevenDayJe")
    public AjaxResult getSevenDayMsje()
    {
        List<String> depNames = bzjtableService.getDepList();
        HashMap<String,List<String>> depNamesMap = new HashMap<>();
        depNamesMap.put("depNames",depNames);
        List<HashMap<String,Object>> mapList = indexService.getSevenDayMsje(depNamesMap);
        AjaxResult ajax = AjaxResult.success();
        ajax.put("data", mapList);
        return ajax;
    }


}
